/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  router.get('/', controller.home.index);
  router.get('/announcement/list', controller.announcement.list);
  router.get('/announcement/:id', controller.announcement.read);
  router.post('/announcement', controller.announcement.create);
  router.delete('/announcement/:id', controller.announcement.delete);
  router.put('/announcement/:id', controller.announcement.update);

  router.get('/medicinal/list', controller.medicinalFood.list);     // 列出所有药膳
  router.get('/medicinal/:id', controller.medicinalFood.read);      // 读取单个药膳
  router.post('/medicinal', controller.medicinalFood.create);       // 创建药膳
  router.delete('/medicinal/:id', controller.medicinalFood.delete); // 删除药膳
  router.put('/medicinal/:id', controller.medicinalFood.update);    // 更新药膳

  router.post('/user/register', controller.user.register);          // 用户注册
  router.post('/user/login', controller.user.login);                // 用户登录
  router.get('/user/list/listDoctors', controller.user.listDoctors);                   // 列出所有用户
  router.get('/user/list', controller.user.list);                   // 列出所有用户

  router.get('/user/:id', controller.user.read);                    // 读取单个用户
  router.put('/user/:id', controller.user.update);                  // 更新用户信息
  router.delete('/user/:id', controller.user.delete);               // 删除用户
  router.post('/user',controller.user.create);


  router.post('/appointments', controller.appointments.create);
  router.get('/appointments', controller.appointments.allList);
  router.get('/appointments/:id', controller.appointments.read);

  router.get('/appointments/doctor/:doctor_id', controller.appointments.readoctor);
  router.put('/appointments/:id', controller.appointments.update);
  router.delete('/appointments/:id', controller.appointments.delete);
  router.get('/appointments/user/:user_id', controller.appointments.findByUserId);

  router.post('/forum', controller.forum.create); 
  router.get('/forum/:id', controller.forum.read);                   // 读取单个论坛帖子

    router.get('/forum', controller.forum.list);                       // 列出所有论坛帖子
    router.get('/forum/user/:user_id', controller.forum.listByUserId); // 根据用户ID列出论坛帖子
    router.put('/forum/:id', controller.forum.update);                 // 更新论坛帖子
    router.delete('/forum/:id', controller.forum.delete);    
    
    // 上传
    router.post('/upload', controller.upload.upload);
    router.get('/files', controller.files.list);
  
};
